-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle xjc XmlEnumValue in DynamicJAXB enum #2273
Conversation
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use *
in imports. We prefer specific imports like removed part.
...lipse.persistence.core/src/main/java/org/eclipse/persistence/dynamic/DynamicClassLoader.java
Outdated
Show resolved
Hide resolved
...nce.moxy/src/test/resources/org/eclipse/persistence/testing/jaxb/dynamic/xmlenum-numbers.xsd
Outdated
Show resolved
Hide resolved
...nce.moxy/src/test/resources/org/eclipse/persistence/testing/jaxb/dynamic/xmlenum-numbers.xsd
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general please use specific types instead of var
.
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use specific imports instead of ... .*
This should be applied to all changes.
@@ -223,7 +223,7 @@ protected void addMethods(ClassWriter cw, String parentClassType) { | |||
|
|||
protected byte[] createEnum(EnumInfo enumInfo) { | |||
|
|||
String[] enumValues = enumInfo.getLiteralLabels(); | |||
var enumValues = enumInfo.getEnumValues(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use specific type instead of var
.
for (String enumValue : enumValues) { | ||
cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, enumValue, "L" + internalClassName + ";", null, null); | ||
for (var enumValue : enumValues.entrySet()) { | ||
var fv = cw.visitField(Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_STATIC + Opcodes.ACC_ENUM, enumValue.getKey(), "L" + internalClassName + ";", null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var
again.
@@ -92,6 +95,16 @@ public void initialize(DatabaseMapping mapping, Session session) { | |||
super.initialize(mapping, session); | |||
} | |||
|
|||
private String getEnumValue(Enum theEnum) { | |||
try { | |||
Field field = theEnum.getClass().getField(theEnum.name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use (maybe add new method into) https://github.com/eclipse-ee4j/eclipselink/blob/master/moxy/org.eclipse.persistence.moxy/src/main/java/org/eclipse/persistence/jaxb/ReflectionUtils.java
to ensure, that PrivilegedAccessHelper.callDoPrivilegedWithException(
is used instead of direct call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It was merged into master -> upcoming 5.x version. If You want it into EL 4.x please make a backport against 4.0 branch. |
@rfelcman thanks for reviewing. Is it possible to kick off a beta promotion to publish to mvnrepository? |
There is snapshot repo |
To resolve #2272